package cn.ming.leo.core;

import javax.servlet.http.HttpServletRequest;

import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ming.leo.utils.Constant.MsgCode;
import cn.ming.leo.utils.Message;

@ControllerAdvice
public class GlobalDefultExceptionHandler {

	private static final Logger logger = LoggerFactory.getLogger(GlobalDefultExceptionHandler.class);

	// 声明要捕获的异常
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Message<T> defultExcepitonHandler(HttpServletRequest request, Exception e) {
		logger.error("error is exception : ", e);
		return new Message<T>(MsgCode.FAIL.value, e.getMessage());

	}

}
